#include <time.h>
#include "array.h"

int main(int argc, char** argv)
{
    /* initialize random seed: */
    srand ( time(NULL) );

    /*int i;
    const int sz = 20;
    Array *a1 = create_array();

    for(i = 0; i < sz; i++)
    {
        push_back(a1, rand() % 50);
    }

    // print the elements
    for(i = 0; i < a1->num_elements; i++)
    {
        printf("%d: %f \n", i, get_element(a1, i));
    }

    printf("\n");
    push_back(a1, 2000.0);
    // print the elements
    for(i = 0; i < a1->num_elements; i++)
    {
        printf("%d: %f \n", i, get_element(a1, i));
    }

    printf("after sorting\n");
    sort_elements(a1);
    for(i = 0; i < a1->num_elements; i++)
    {
        printf("%d: %f \n", i, get_element(a1, i));
    }

    double median, ave, min, max;
    compute_statistics(a1, &median, &ave, &min, &max);
    printf("median: %f, min: %f, max: %f, average: %f \n", median, min, max, ave);
    */
    int i, j; 
    Array** time_array = (Array **)malloc(sizeof(Array*)*10);
    size_t num_elements = 2;
    double median, mean, min, max;

    for(i = 0; i < 10; i++)
    {
        time_array[i] = create_array();
        for(j = 0; j < num_elements; j++)
        {
            push_back(time_array[i], rand() %50/20000.0);
        }
    }

    for(i = 0; i < 10; i++)
    {

        compute_statistics(time_array[i], &median, &mean, &min, &max);
        for(j = 0; j < time_array[i]->num_elements; j++)
        {
            printf(" %f \n", get_element(time_array[i], j));
        }

        printf("%d: (median)%f (mean)%f (min)%f (max)%f\n\n", i, median, mean, min, max);
        free_array(time_array[i]);
    }

    free(time_array);

    return 1;

}
